import com.raspoid.Tools;
import com.raspoid.additionalcomponents.PCA9685;
import com.raspoid.additionalcomponents.PCA9685.PCA9685Channel;
import com.raspoid.additionalcomponents.servomotor.ServoMotor;
import com.raspoid.additionalcomponents.servomotor.TowerProMG90S;

public class Pwm {

	public static void main(String[] args) throws InterruptedException{


		// Comment/Uncomment the corresponding sections to use PCA9685
        // or hardware PWM pins from the Raspberry Pi
        ServoMotor motor;
        
        // Using a PWM pin
        //motor = new TowerProMG90S(PWMPin.PWM1); // NOSONAR
        
        // Using a PCA9685
        motor = new TowerProMG90S(new PCA9685(), PCA9685Channel.CHANNEL_01); // NOSONAR
        
        motor.setAngle(90);
        Tools.sleepMilliseconds(100000);
        
        double[] angles = {0, 45, 90, 135, 180, 135, 90, 45, 0};
        
        for(int i = 0; i < angles.length; i++) {
            motor.setAngle(angles[i]);
            Tools.log("position angle: " + motor.getPositionAngle());
            Tools.sleepMilliseconds(1500);
        }
        
	
	}
}
